package com.tang.websocket.v1.handler;

import com.tang.websocket.v1.message.WebSocketMessage;
import com.tang.websocket.v1.session.WebSocketSession;

import java.io.IOException;

/**
 * @author Tang
 * @classname WebsocketHandlerDecorator
 * @description [  ]
 * @date 2022/11/28 22:18
 */
public class WebsocketHandlerDecorator implements WebSocketHandler {

    protected WebSocketHandler proxyWebSocketHandler;

    public WebsocketHandlerDecorator(WebSocketHandler webSocketHandler) {
        this.proxyWebSocketHandler = webSocketHandler;
    }

    @Override
    public void onOpen(WebSocketSession webSocketSession) {
        this.proxyWebSocketHandler.onOpen(webSocketSession);
    }

    @Override
    public void onMessage(WebSocketSession webSocketSession, WebSocketMessage<?> message) throws IOException {
        this.proxyWebSocketHandler.onMessage(webSocketSession, message);
    }

    @Override
    public void onClose(WebSocketSession webSocketSession) {
        this.proxyWebSocketHandler.onClose(webSocketSession);
    }

    @Override
    public void onError(WebSocketSession webSocketSession, Throwable e) {
        this.proxyWebSocketHandler.onError(webSocketSession, e);
    }
}
